/**
 * 
 */
package edu.umuc.cmsc495_final_project;

import java.util.Iterator;

/**
 * @author dlipp
 *
 */
public class Verification {
	
	static DataBase db = null; 
	private String passkey ="";
	private employee emp;
	
	protected Verification(DataBase db, String passkey){	
		Verification.db = db;
		this.passkey = passkey;
	}

	protected boolean isValid() {
		
		Iterator<employee> iterator = db.getEmployees().iterator();   

		while(iterator.hasNext()){			
			employee temp = iterator.next();
			//System.out.println("current user checking: " + temp.toString());
			
			if(temp.getPasskey() == Integer.parseInt(passkey)){
				System.out.println("Found user: " + temp.toString());
				setEmp(temp);
				return true;
			}
		}
		return false;
	}

	private void setEmp(employee temp) {
		emp = temp;
		
	}

	public employee getEmp() {
		return emp;
	}
}
